<template>
	<!--新闻信息管理-->
	<div class="container-app">
		<div style="margin-bottom:15px;">
			<el-button v-if="hasAdd" size="small" type="success" @click="addLine"><i class="el-icon-plus"></i>{{addTitle}}</el-button>
			<el-button v-if="hasDel" size="small" type="danger" @click="removeLine"><i class="el-icon-delete"></i>{{delTitle}}</el-button>
			<el-button v-if="hasUpdate" size="small" type="primary" @click="changeLine"><i class="el-icon-edit-outline"></i>{{updateTitle}}</el-button>
			<span class="right-search">
	        <el-input @change="findLine" v-model="findData" class="listinput" size="small" placeholder="输入关键字搜索" style="width:300px;">
	          <el-button @click="findLine" slot="append" icon="el-icon-search"></el-button>
	        </el-input>
	        <el-button @click="resetLine" size="mini"><i class="el-icon-refresh"></i>重置</el-button>
	      </span>
		</div>
		<!--新闻信息管理列表-->
		<el-table @selection-change="getRow" :data="tableData" tooltip-effect="dark" style="width: 100%" border v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.5)">
			<el-table-column type="selection" width="55"></el-table-column>
			<el-table-column prop="nType" label="类型">
				<template slot-scope="scope">{{scope.row.nType | formatnType}}</template>
			</el-table-column>
			<el-table-column prop="nTitle" label="标题"></el-table-column>
			<el-table-column prop="nSource" label="来源"></el-table-column>
			<el-table-column prop="isPublish" label="是否发布">
				<template slot-scope="scope">
					<span v-if="scope.row.isPublish == 1" style="color: green;">已发布</span>
					<span v-else-if="scope.row.isPublish == 0" style="color: #de8a09;">未发布</span>
					<span v-else></span>
				</template>
			</el-table-column>
			<el-table-column prop="pbTime" label="发布时间" width="160"></el-table-column>
			<el-table-column prop="isAttach" label="是否有附件">
				<template slot-scope="scope">{{scope.row.isAttach | formatisAttach}}</template>
			</el-table-column>
			<el-table-column prop="createTime" label="创建时间" width="160"></el-table-column>
			<el-table-column label="操作" width="220">
				<template slot-scope="scope">
					<el-button type="success" size="mini" @click="viewLine(scope.row)">
						<i class="el-icon-check"></i> 查看详情
					</el-button>
					<el-button v-if="hasCheck" size="small" type="primary" @click="checkLine(scope.row)"><i class="el-icon-plus"></i>发布</el-button>
				</template>
			</el-table-column>
		</el-table>
		<el-col :span="24" class="paging">
			<span>总条数：{{dataTotal}}</span>
			<el-pagination @current-change="changePage" :page-size="10" :total="dataTotal" background layout="prev, pager, next" style="float:right;"></el-pagination>
		</el-col>
		<!--新增修改对话界面-->
		<el-dialog :title="title" :visible.sync="isDialog" width="60%" :before-close="handleClose" :close-on-click-modal='false' v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.5)">
			<el-form size="small" :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px" class="form-submit">
				<el-form-item label="类型：" prop="nType">
		          <el-select v-model="ruleForm.nType" size="small" style="width:80%" placeholder="请选择类型">
		            <el-option
		              v-for="item in nTypeList"
		              :key="item.value"
		              :label="item.title"
		              :value="item.value">
		            </el-option>
		          </el-select>
		        </el-form-item>
		        <el-form-item label="标题：" prop="nTitle">
		          <el-input size="small" v-model="ruleForm.nTitle"  placeholder="请输入标题"></el-input>
		        </el-form-item>
				<el-form-item label="来源：" prop="nSource">
					<el-input size="small" v-model="ruleForm.nSource" placeholder="请输入来源"></el-input>
				</el-form-item>
				<el-form-item label="编辑：" prop="nEditor">
					<el-input size="small" v-model="ruleForm.nEditor" placeholder="请输入编辑"></el-input>
				</el-form-item>
				<el-form-item label="简介：" prop="nDetail">
					<el-input type="textarea" resize="none" :rows="3" v-model="ruleForm.nDetail" placeholder="请输入简介"></el-input>
				</el-form-item>
				<el-form-item label="发布时间：" prop="pbTime">
					<el-date-picker type="datetime" value-format="yyyy-MM-dd HH:mm:ss" style="width:100%" v-model="ruleForm.pbTime" placeholder="请输入发布时间"></el-date-picker>
				</el-form-item>
				 <el-form-item label="缩略图：" prop="nMinipic">
				 	<el-upload
					  class="avatar-uploader"
					  :action="action"
					  :show-file-list="false"
					  :on-success="handleSuccessnMinipic">
					  <img v-if="imageUrl" :src="imageUrl" class="avatar">
					  <i v-else class="el-icon-plus avatar-uploader-icon"></i>
					  <div slot="tip" class="el-upload__tip">请上传的缩略图尺寸保持为106*80</div>
					</el-upload>
		        </el-form-item>
				<el-form-item label="内容：" prop="nContent">
					<el-upload
				      v-show="false"
				      ref="upload"
				      class="upload-nContent"
				      :action="action"
				      :before-upload="beforeUpload"
				      :on-success="upScuccess"
				      :on-error="uploadError"
				    />
				    <quill-editor
				      ref="myQuillEditor"
				      v-model="ruleForm.nContent"
				      :options="editorOption"
				      @blur="onEditorBlur($event)"
				      @focus="onEditorFocus($event)"
				      @change="onEditorChange($event)"
				    />
				</el-form-item>
				<el-form-item label="是否有附件：" prop="isAttach">
		          	<el-radio v-model="ruleForm.isAttach" label="1" border>有</el-radio>
    				<el-radio v-model="ruleForm.isAttach" label="0" border>无</el-radio>
		        </el-form-item>
		        <el-form-item label="附件名称：" v-if="ruleForm.isAttach == 1" prop="nTitle1">
					<el-input size="small" v-model="ruleForm.nTitle1" placeholder="请输入附件名称"></el-input>
				</el-form-item>
				<el-form-item label="附件：" v-if="ruleForm.isAttach == 1" prop="atUrl" class="avatar-uploader">
		            <el-upload
					  class="upload-demo"
					  :action="action"
					  :on-preview="handlePreview"
					  :on-remove="handleRemoveatUrl"
					  :on-success="handleSuccessatUrl"
					  :file-list="atUrlfileList"
					  :auto-upload="true">
					  <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
					  <div slot="tip" class="el-upload__tip"></div>
					</el-upload>
		        </el-form-item>
			</el-form>
			<span slot="footer" style="padding-right:30px;">
	        	<el-button size="small" type="success" @click="submitForm('ruleForm')">保存</el-button>
	        	<el-button v-show="changeVisible" size="small" type="warning" @click="resetForm('ruleForm')">重置</el-button>
	       		<el-button size="small" @click="cancleForm('ruleForm')">取消</el-button>
	        </span>
		</el-dialog>
		<!--查看详情-->
		<el-dialog title="新闻动态信息" :visible.sync="isDetails" width="60%" :before-close="handleClose" :close-on-click-modal='false' v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.5)">
			<el-form size="small" :model="ruleForm" ref="ruleForm" label-width="120px" class="form-submit">
				<el-form-item label="类型" prop="nTypeName">
		          <el-input size="small" v-model="ruleForm.nTypeName" readonly></el-input>
		        </el-form-item>
		        <el-form-item label="标题" prop="nTitle">
		          <el-input size="small" v-model="ruleForm.nTitle" readonly></el-input>
		        </el-form-item>
				<el-form-item label="来源" prop="nSource">
					<el-input size="small" v-model="ruleForm.nSource" readonly></el-input>
				</el-form-item>
				<el-form-item label="编辑" prop="nEditor">
					<el-input size="small" v-model="ruleForm.nEditor" readonly></el-input>
				</el-form-item>
				<el-form-item label="简介：" prop="nDetail">
					<el-input type="textarea" resize="none" :rows="3" v-model="ruleForm.nDetail" readonly></el-input>
				</el-form-item>
				<el-form-item label="发布时间" prop="pbTime">
					<el-input size="small" v-model="ruleForm.pbTime" readonly></el-input>
				</el-form-item>
				<el-form-item label="缩略图：" prop="nMinipic">
					<img :src="ruleForm.nMinipic" style="width: 160px; height: 160px" />
				</el-form-item>
				<el-form-item label="新闻内容" prop="nContent">
					<div v-html="ruleForm.nContent" style="height: 500px;overflow: auto;border: 1px solid #dcdfe6;"></div>
				</el-form-item>
				<el-form-item label="是否有附件" prop="isAttach">
					<el-input size="small" v-model="ruleForm.isAttachName" readonly></el-input>
				</el-form-item>
				<el-form-item label="附件名称：" v-if="ruleForm.isAttach == 1" prop="nTitle1">
					<el-input size="small" v-model="ruleForm.nTitle1" readonly></el-input>
				</el-form-item>
				<el-form-item label="附件：" v-if="ruleForm.isAttach == 1" prop="atUrl">
					<p v-for="item in atUrlfileList"><a target='_blank' :href="item.url">{{item.name}}</a></p>
				</el-form-item>
			</el-form>
			<span slot="footer" style="padding-right:30px;">
        <el-button size="small" @click="cancleForm('ruleForm')">关闭</el-button>
      </span>
		</el-dialog>
	</div>
</template>

<script>
	import {      
		getserver,
		postserver,
		postjsonserver,
		getImgUrl
	} from '@/api/basicFunction'
	
import { quillEditor } from 'vue-quill-editor'
import { parseTime } from '@/utils/index'
	export default {
		 components: { quillEditor },
		  props: {
		    str: {
		      type: String,
		      default: ''
		    }
		  },
		data() {
			return {
				inputVisible: false,
				inputValue: '',
				isDetails: false,
				isDialog: false,
				loading: false,
				isUsable: 1,
				changeVisible: true,
				title:'发布新闻信息',
				imageUrl:'',
				selectData: [],
				dataPage: 1,
				dataTotal: 1,
				tableData: [],
				atUrlfileList:[],
				atUrlList:[],
				action: process.env.SAVE_IMG_API+'transferMangeImg',
				modelList:[],
				nTypeList:[{
					'value':'',
					'title':'请选择新闻类型'
				},{
					'value':'1',
					'title':'新闻'
				},{
					'value':'2',
					'title':'政策'
				},{
					'value':'3',
					'title':'通知'
				},{
					'value':'4',
					'title':'观点'
				},{
					'value':'5',
					'title':'科普'
				}],
				
				editorOption: { // 富文本编辑器配置
		        placeholder: '请在这里输入',
		        modules: {
		          toolbar: {
		            container: [
		              ['bold', 'italic', 'underline', 'strike'], // 加粗，斜体，下划线，删除线
		              // ['blockquote', 'code-block'], // 引用，代码块
		              [{ 'header': 1 }, { 'header': 2 }], // 标题，键值对的形式；1、2表示字体大小
		              [{ 'list': 'ordered' }, { 'list': 'bullet' }], // 列表
		              [{ 'script': 'sub' }, { 'script': 'super' }], // 上下标
		              [{ 'indent': '-1' }, { 'indent': '+1' }], // 缩进
		              [{ 'direction': 'rtl' }], // 文本方向
		              // [{ 'size': ['small', false, 'large', 'huge'] }], // 字体大小
		              // [{ 'header': [1, 2, 3, 4, 5, 6, false] }], // 几级标题
		              [{ 'color': [] }, { 'background': [] }], // 字体颜色，字体背景颜色
		              // [{ 'font': [] }], // 字体
		              [{ 'align': [] }], // 对齐方式
		              ['clean'], // 清除字体样式
		              ['image'] // 上传图片、上传视频
		            ],
		            handlers: {
		              'image': function(value) {
		                if (value) {
		                  document.querySelector('.upload-nContent input').click()
		                } else {
		                  this.quill.format('image', false)
		                }
		              }
		            }
		          }
		        },
		        theme: 'snow'
		      },
				ruleForm: {
					id: '',
					nType: '1',
					nTitle : '',
					nSource : '',
					nEditor : '',
					nDetail : '',
					nMinipic : '',
					nContent : '',
					isAttach: '0',
					nTitle1: '',
					pbTime:''
				},
				removeIds: [],
				selectId: '',
				isAdd: true,
				findData: '',
				hasAdd: false,
				hasDel: false,
				hasUpdate: false,
				hasCheck: false,
				addTitle: '新增',
				updateTitle: '修改',
				delTitle: '删除',
				checkTitle: '审核',
				rules: {
					stTitle: [{
						required: true,
						trigger: 'blur',
						message: '请输入成果名称'
					}],
					stBelong: [{
						required: true,
						trigger: 'blur',
						message: '请输入成果所属'
					}],
					stResName: [{
						required: true,
						trigger: 'blur',
						message: '请选择发布人'
					}],
					stResTime: [{
						required: true,
						trigger: 'blur',
						message: '请输入发布时间'
					}]
				},
			}
		},
		filters: {
			formatnType(value) {//1:新闻 2:政策 3:通知 4:观点 5:科普
				if(value == '1'){
					return '新闻'
				}else if(value == '2'){
					return '政策'
				}else if(value == '3'){
					return '通知'
				}else if(value == '4'){
					return '观点'
				}else if(value == '5'){
					return '科普'
				}else {
					return ''
				}
			},
			formatisAttach(value){
				if(value == '1'){
					return '有'
				}else if(value == '0'){
					return '无'
				}else {
					return ''
				}
			},
			formatisPublish(value){
				if(value == '1'){
					return '已发布'
				}else if(value == '0'){
					return '未发布'
				}else {
					return ''
				}
			}
		},
		computed: {
		    editor() {
		      return this.$refs.myQuillEditor.quill
		    }
		  },
		  created() {
		    this.editContent = this.str // JSON.parse(JSON.stringify(this.str))
		  },
		mounted() {
			this.getPageList()
			this.getJur()
			this.getModelAllList()
		},
		methods: {
			showHtml:function(str){
                        return str
                        .replace(str ? /&(?!#?\w+;)/g : /&/g, '&amp;')
                        .replace(/&lt;/g,"<")
                        .replace(/&gt;/g,">")
                        .replace(/&quot;/g,"\"")
                        .replace(/&#39;/g, "\'");
                   },
			handleRemove(file, fileList) {
		    },
		    handlePreview(file) {
		    },
			beforeUpload(file) {
     		 console.log('上传前，可在此插入loading动画')
   			},
		    upScuccess(res, file) {
		      console.log(res)
		      const quill = this.$refs.myQuillEditor.quill
		      if (res.result) {
		        const length = quill.getSelection().index // 获取光标所在位置
		        quill.insertEmbed(length, 'image', getImgUrl(res.result)) // 插入图片
		        quill.setSelection(length + 1) // 调整光标位置到最后
		      } else {
		        this.$message.error('图片上传失败1')
		      }
		    },
		    uploadError() {
		      this.$message.error('图片上传失败1')
		    },
		    onEditorReady(editor) { // 准备编辑器
		    },
		    onEditorBlur() {}, // 失去焦点事件
		    onEditorFocus(val, editor) {}, // 获得焦点事件
		    onEditorChange() {
		      this.$emit('editorContent', this.editContent)
		    }, // 内容改变事件
        	getJur() {
				const self = this
				self.$store.dispatch('Juage', self.$store.clickMenuId).then(res => {
					if(res.code == '200') {
						res.data.forEach(item => {
							if(item.type == '3') {
								self.hasAdd = true
								self.addTitle = item.title
							}
							if(item.type == '5') {
								self.hasDel = true
								self.delTitle = item.title
							}
							if(item.type == '4') {
								self.hasUpdate = true
								self.updateTitle = item.title
							}
							if(item.type == '7') {
								self.hasCheck = true
								self.checkTitle = item.title
							}
						})
					} else if(res.code !== '507') {
						this.$message({
							type: 'error',
							message: res.message
						})
					}
				})
			},
			getPageList() {
				const para = {
					pageIndex: this.dataPage,
					pageSize: 10
				}
				this.loading = true
				getserver(para, "/news/getPageList").then(res => {
					if(res.code == '200') {
						this.dataTotal = res.data.total
						this.tableData = res.data.records
						console.log(this.tableData)
					} else {
						this.$message({
							type: 'error',
							message: res.message
						})
					}
					this.loading = false
				})
			},
			getModelAllList(){
				getserver({mdType:1}, "/md/getDetailAll").then(res => {
					if(res.code == '200') {
						let _arr =[]
						let _v = {
								mvId:'',
								mvTitle:'请选择模块值信息'
							}
						for(let i=0;i<res.data.length;i++){
							_arr.push({
								mdId:'',
								mdTitle:'',
								mdType: '',
								mvId:'',
								mvTitle:''
							})
							res.data[i].mdVId = ''
							res.data[i].mvList.unshift(_v)
						}
						this.modelPropsList = _arr;
						this.modelList = res.data
						console.log(this.modelPropsList,this.modelList)
					} else {
						this.$message({
							type: 'error',
							message: res.message
						})
					}
				})
			},
			selectModel(e,obj,index){
				for(let i=0;i<this.modelPropsList.length;i++){
					if(i == index){
						if(e){
							this.modelPropsList[i].mvId = e 
							this.modelPropsList[i].mdId = obj.mdId
							this.modelPropsList[i].mdType = obj.mdType 
							this.modelPropsList[i].mdTitle = obj.mdTitle 
						}else{
							this.modelPropsList[i].mvId = '' 
							this.modelPropsList[i].mdId = ''
							this.modelPropsList[i].mdType = ''
							this.modelPropsList[i].mdTitle = ''
						}
						
					}
				}
			},
			changePage(val) {
				this.dataPage = val
				this.getPageList()
			},
			handleClose() {
				this.isDialog = false
				this.isDetails = false
			},
			submitForm(formName) {
				const self = this
				self.$refs[formName].validate((valid) => {
					if(valid) {
						let para = self.ruleForm
						let _tagList = []
						
						
						let _picList = []
						self.atUrlList.forEach(item => {
							_picList.push({'nTitle':item.nTitle,'atUrl':item.atUrl})
						})
						para.fileList = _picList
						para.isAttach = parseInt(self.ruleForm.isAttach)
						para.nType = parseInt(self.ruleForm.nType)
						delete para.nTitle1
						//return false
						//console.log(para,self.levelEvaluationfileList,'result')
						//return false
						if(self.isAdd) {
							delete para.id
							//添加信息
							postjsonserver(para, "/news/add").then(res => {
								if(res.code == '200') {
									this.$message({
										type: 'success',
										message: res.message
									})
									this.getPageList()
								} else {
									this.$message({
										type: 'error',
										message: res.message
									})
								}
								self.isDialog = false
								self.restData()
								this.$refs[formName].resetFields()
							})
						} else {
							//修改信息
							postjsonserver(para, "/news/update").then(res => {
								if(res.code == '200') {
									this.$message({
										type: 'success',
										message: res.message
									})
									this.getPageList()
								} else {
									this.$message({
										type: 'error',
										message: res.message
									})
								}
								self.isDialog = false
								self.restData()
								this.$refs[formName].resetFields()
							})
						}
					} else {
						console.log('error submit!!')
						return false
					}
				})
			},
			resetForm(formName) {
				this.$refs[formName].resetFields()
				//this.restData()
			},
			cancleForm(formName) {
				this.$refs[formName].resetFields()
				this.isDialog = false
				this.isDetails = false
			},
			removeLine() {
				if(this.selectData.length) {
					this.$confirm('删除该数据, 是否继续?', '提示', {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						type: 'warning'
					}).then(() => {
						const para = {
							ids: this.removeIds.toString()
						}
						this.loading = true
						postserver(para, "/news/delete").then(res => {
							if(res.code == '200') {
								this.$message({
									type: 'success',
									message: res.message
								})
								this.getPageList()
							} else {
								this.$message({
									type: 'success',
									message: res.message
								})
							}
							this.loading = false
						})
					}).catch(() => {
						this.$message({
							type: 'info',
							message: '已取消删除'
						})
					})
				} else {
					this.$message('请先选择需要删除的信息！')
				}
			},
			restData() {
				const self = this
				self.ruleForm.id = ''
				self.ruleForm.nType = ''
				self.ruleForm.nTitle = ''
				self.ruleForm.nSource = ''
				self.ruleForm.nEditor = ''
				self.ruleForm.nMinipic = ''
				self.ruleForm.nContent = ''
				self.ruleForm.isAttach = '0'
				self.ruleForm.nTitle1 = ''
				self.ruleForm.pbTime = ''
				self.atUrlfileList = []
				self.atUrlList = []
				self.imageUrl = ''
			},
			addLine() {
				const self = this
				self.title = '发布新闻动态信息'
				self.restData()
				self.isDialog = true
				self.changeVisible = true
				self.isAdd = true
				
			},
			changeLine() {
				const self = this
				if(self.selectData.length && self.selectData.length === 1) {
					self.isAdd = false
					self.title = '修改新闻动态信息'
					self.restData()
					self.loading = true
					getserver({id:self.selectData[0].id}, "/news/info").then(res => {
						if(res.code == '200') {
							self.ruleForm.id = res.data.id
						
							res.data.fileList.forEach(item => {
		    					self.atUrlList.push({'name':'','atUrl':item.atUrl,nTitle: item.nTitle,})
								self.atUrlfileList.push({name:item.nTitle,url:getImgUrl(item.atUrl),nTitle: item.nTitle,response:{result:item.atUrl}})
							})
							
							self.ruleForm.nType = res.data.nType
							self.ruleForm.nTitle = res.data.nTitle
							self.ruleForm.nSource = res.data.nSource
							self.ruleForm.nEditor = res.data.nEditor
							self.ruleForm.nMinipic = res.data.nMinipic
							self.ruleForm.nContent = res.data.nContent
							self.ruleForm.nDetail = res.data.nDetail
							self.ruleForm.isAttach = String(res.data.isAttach)
							self.ruleForm.pbTime = parseTime(res.data.pbTime)
							self.imageUrl = getImgUrl(res.data.nMinipic)
							
						} else {
							self.$message({
								type: 'error',
								message: res.message
							})
						}
						self.loading = false
					})
					
					self.isDialog = true
					self.changeVisible = false
					self.isWine = false
					
					self.selectId = self.selectData[0].id
				} else {
					this.$message({
						type: 'warning',
						message: '请选择一条信息进行修改！'
					})
				}
			},
			getRow(selection) {
				const self = this
				self.removeIds = []
				self.selectData = selection
				selection.forEach(item => {
					self.removeIds.push(item.id)
				})
			},
			findLine() {
				//let keyword = encodeURIComponent(this.findData)
				const para = {
					row: 10,
					page: 1,
					keyword: this.findData
				}
				this.loading = true
				//关键字搜索行
				postserver(para, "/news/getPageList").then(res => {
					if(res.code == '200') {
						this.loading = false
						this.dataTotal = res.data.total
						this.tableData = res.data.records
					} else {
						this.$message({
							type: 'error',
							message: res.message
						})
					}
					this.loading = false
				})
			},
			resetLine() {
				this.findData = ''
			},
			viewLine(obj) {
				const self = this
				self.restData()
				self.loading = true
				getserver({id:obj.id}, "/news/info").then(res => {
						if(res.code == '200') {
							self.ruleForm.id = res.data.id
						
							res.data.fileList.forEach(item => {
		    					self.ruleForm.nTitle1 = item.nTitle
								self.atUrlfileList.push({name:item.nTitle,url:getImgUrl(item.atUrl),nTitle: item.nTitle,response:{result:item.atUrl}})
							})
							
							self.ruleForm.nType = res.data.nType
							self.ruleForm.nTitle = res.data.nTitle
							self.ruleForm.nSource = res.data.nSource
							self.ruleForm.nEditor = res.data.nEditor
							self.ruleForm.nMinipic = getImgUrl(res.data.nMinipic)
							self.ruleForm.nContent = res.data.nContent
							self.ruleForm.nDetail = res.data.nDetail
							self.ruleForm.isAttach = String(res.data.isAttach)
							self.ruleForm.pbTime = parseTime(res.data.pbTime)
							self.imageUrl = getImgUrl(res.data.nMinipic)
							self.ruleForm.isAttachName = self.$options.filters['formatisAttach'](res.data.isAttach)
							self.ruleForm.nTypeName = self.$options.filters['formatnType'](res.data.nType)
						} else {
							this.$message({
								type: 'error',
								message: res.message
							})
						}
						self.loading = false
					})
				self.isDetails = true
				self.selectId = obj.id
			},
		    //上传缩略图
		    handleSuccessnMinipic(res, file) {
		        this.imageUrl = URL.createObjectURL(file.raw);
		        this.ruleForm.nMinipic = process.env.GET_IMG_API+ res.result
		    },
		    //附件
		    handleSuccessatUrl(response,file,levelEvaluationfileList){
		    	this.atUrlList.push({'name':'atUrl','atUrl':process.env.GET_IMG_API+response.result,nTitle: file.name})
		    },
		    handleRemoveatUrl(file, fileList) {
		    	console.log(this.atUrlList)
		        for(let i=0;i<this.atUrlList.length;i++){
		        	if(this.atUrlList[i].atUrl == file.response.result){
		        		this.atUrlList.splice(i,1)
		        	}
		        }
		    },
			checkLine(obj){    
				if(obj.isPublish == 1){
					this.$message('当前数据已发布！')
				}else{
					this.$confirm('发布该数据, 是否继续?', '提示', {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						type: 'warning'
					}).then(() => {
						const para = {
							id: obj.id
						}
						postserver(para, "/news/release").then(res => {
							if(res.code == '200') {
								this.$message({
									type: 'success',
									message: res.message
								})
								this.getPageList()
							} else {
								this.$message({
									type: 'success',
									message: res.message
								})
							}
						})
					}).catch(() => {
						this.$message({
							type: 'info',
							message: '已取消发布'
						})
					})
				}
			}
		}
	}
</script>

<style scoped>
	.paging {
		padding: 15px;
		padding-right: 0;
	}
	
	.form-submit {
		margin: 0;
		padding-right: 30px;
	}
	
	.el-dialog__header {
		text-align: center;
	}
	.tree-box{
		height: 180px;
	    overflow: auto;
	    z-index: 999;
	    width: 100%;
	}
	.el-tree{
		min-height: 120px;
	}
	.tree-box{
		padding: 20px;
	    border: 1px solid #dedede;
	    position: absolute;
	    z-index: 999;
	    width: 100%;
	    background: #f1f1f1;
	    margin-top: 10px;
    }
    .tree-box div.triangle{
    	width: 0;
	    height: 0;
	    border-width: 10px;
	    border-style: solid;
	    border-color: transparent transparent #f1f1f1 transparent;
	    font-size: 0;
	    line-height: 0;
	    position: absolute;
	    top: -20px;
    }
    .isactive{
    	background: #1580ef;
    	color: #fff;
    }
/*    .el-upload{
    	border: 1px solid #dedede !important;
    }
   .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
  .ql-container{
  	height: 350px !important;
  }
  .ql-container.ql-snow{
  	height: 350px;
  }*/
</style>
<style>
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;   
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px; 
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
   .ql-container{
  	height: 350px !important;
  }
  .ql-container.ql-snow{           
  	height: 350px;
  }
</style>
